Attribute VB_Name = "Module2"
Global bz1, bz2, bz3, bz4, bz5, bz6, bz7, bz8, bz9, bz10, bz11, bz12 As Boolean
  Public Function rintdata(ByVal qsw As Integer, ByVal zfc As String) As Double
                    Dim Result2 As Double
                    Result2 = 0
                    If Mid(zfc, qsw + 1, 1) = "A" Then
                        Result2 = 10 * 16 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 1, 1) = "B" Then
                        Result2 = 11 * 16 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 1, 1) = "C" Then
                        Result2 = 12 * 16 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 1, 1) = "D" Then
                        Result2 = 13 * 16 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 1, 1) = "E" Then
                        Result2 = 14 * 16 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 1, 1) = "F" Then
                        Result2 = 15 * 16 * 16 + Result2
                    Else
                        Result2 = Val(Mid(zfc, qsw + 1, 1)) * 16 * 16 + Result2
                    End If

                    

                    If Mid(zfc, qsw + 2, 1) = "A" Then
                        Result2 = 10 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 2, 1) = "B" Then
                        Result2 = 11 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 2, 1) = "C" Then
                        Result2 = 12 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 2, 1) = "D" Then
                        Result2 = 13 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 2, 1) = "E" Then
                        Result2 = 14 * 16 + Result2
                    ElseIf Mid(zfc, qsw + 2, 1) = "F" Then
                        Result2 = 15 * 16 + Result2
                    Else
                        Result2 = Result2 + Val(Mid(zfc, qsw + 2, 1)) * 16
                    End If

            If Mid(zfc, qsw + 3, 1) = "A" Then
                Result2 = 10 + Result2
            ElseIf Mid(zfc, qsw + 3, 1) = "B" Then
                Result2 = 11 + Result2
            ElseIf Mid(zfc, qsw + 3, 1) = "C" Then
                Result2 = 12 + Result2
            ElseIf Mid(zfc, qsw + 3, 1) = "D" Then
                Result2 = 13 + Result2
            ElseIf Mid(zfc, qsw + 3, 1) = "E" Then
                Result2 = 14 + Result2
            ElseIf Mid(zfc, qsw + 3, 1) = "F" Then
                Result2 = 15 + Result2
            Else
                Result2 = Val(Mid(zfc, qsw + 3, 1)) + Result2
                
            End If
        If Mid(zfc, qsw, 1) = "8" Then
            Result2 = -1 * Result2
        ElseIf Mid(zfc, qsw, 1) = "9" Then
            Result2 = -1 * (16 * 16 * 16 + Result2)
        ElseIf Mid(zfc, qsw, 1) = "A" Then
            Result2 = -1 * (2 * 16 * 16 * 16 + Result2)
        ElseIf Mid(zfc, qsw, 1) = "B" Then
            Result2 = -1 * (3 * 16 * 16 * 16 + Result2)
        ElseIf Mid(zfc, qsw, 1) = "C" Then
            Result2 = -1 * (4 * 16 * 16 * 16 + Result2)
        ElseIf Mid(zfc, qsw, 1) = "D" Then
            Result2 = -1 * (5 * 16 * 16 * 16 + Result2)
        ElseIf Mid(zfc, qsw, 1) = "E" Then
            Result2 = -1 * (6 * 16 * 16 * 16 + Result2)
        ElseIf Mid(zfc, qsw, 1) = "F" Then
            Result2 = -1 * (7 * 16 * 16 * 16 + Result2)
        Else
            Result2 = Val(Mid(zfc, qsw, 1)) * 16 * 16 * 16 + Result2
    End If


           rintdata = Result2

  End Function
   Public Function rpotdata(ByVal qsw As Integer, ByVal zfc As String) As Double
                    Dim Result1 As Double
                    Result1 = 0
                    If Mid(zfc, qsw, 1) = "A" Then
                        Result1 = 10 * (16 ^ 3) + Result1
                    ElseIf Mid(zfc, qsw, 1) = "B" Then
                        Result1 = 11 * (16 ^ 3) + Result1
                    ElseIf Mid(zfc, qsw, 1) = "C" Then
                        Result1 = 12 * (16 ^ 3) + Result1
                    ElseIf Mid(zfc, qsw, 1) = "D" Then
                        Result1 = 13 * (16 ^ 3) + Result1
                    ElseIf Mid(zfc, qsw, 1) = "E" Then
                        Result1 = 14 * (16 ^ 3) + Result1
                    ElseIf Mid(zfc, qsw, 1) = "F" Then
                        Result1 = 15 * (16 ^ 3) + Result1
                    Else
                        Result1 = Val(Mid(zfc, qsw, 1)) * (16 ^ 3) + Result1
                    End If
                    If Mid(zfc, qsw + 1, 1) = "A" Then
                        Result1 = 10 * 16 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 1, 1) = "B" Then
                        Result1 = 11 * 16 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 1, 1) = "C" Then
                        Result1 = 12 * 16 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 1, 1) = "D" Then
                        Result1 = 13 * 16 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 1, 1) = "E" Then
                        Result1 = 14 * 16 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 1, 1) = "F" Then
                        Result1 = 15 * 16 * 16 + Result1
                    Else
                        Result1 = Val(Mid(zfc, qsw + 1, 1)) * 16 * 16 + Result1
                    End If

                    

                    If Mid(zfc, qsw + 2, 1) = "A" Then
                        Result1 = 10 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 2, 1) = "B" Then
                        Result1 = 11 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 2, 1) = "C" Then
                        Result1 = 12 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 2, 1) = "D" Then
                        Result1 = 13 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 2, 1) = "E" Then
                        Result1 = 14 * 16 + Result1
                    ElseIf Mid(zfc, qsw + 2, 1) = "F" Then
                        Result1 = 15 * 16 + Result1
                    Else
                        Result1 = Val(Mid(zfc, qsw + 2, 1)) * 16 + Result1
                    End If

            If Mid(zfc, qsw + 3, 1) = "A" Then
                Result1 = 10 + Result1
            ElseIf Mid(zfc, qsw + 3, 1) = "B" Then
                Result1 = 11 + Result1
            ElseIf Mid(zfc, qsw + 3, 1) = "C" Then
                Result1 = 12 + Result1
            ElseIf Mid(zfc, qsw + 3, 1) = "D" Then
                Result1 = 13 + Result1
            ElseIf Mid(zfc, qsw + 3, 1) = "E" Then
                Result1 = 14 + Result1
            ElseIf Mid(zfc, qsw + 3, 1) = "F" Then
                Result1 = 15 + Result1
            Else
                Result1 = Val(Mid(zfc, qsw + 3, 1)) + Result1
                
            End If
                    


           rpotdata = Result1

  End Function
  Public Function realdata(rint As Double, rpot As Double) As Single
  realdata = Val(rint & "." & rpot)
  End Function
    Public Function getdatafromplc(ByVal BackStr As String, d As Integer) As Long
'  If Mid(BackStr, 1, 1) <> "@" Then
'        Exit Function
'        End If
'            form6.MSComm1.InBufferSize = 0
'           If Text1.Text <> A Then
'            Print A
'           End If
If Mid(BackStr, 1, 1) = "@" Then
           Dim Result1 As Long
           
           Result1 = 0
           
        If Mid(BackStr, d, 1) = "A" Or Mid(BackStr, d, 1) = "B" Or Mid(BackStr, d, 1) = "C" Or Mid(BackStr, d, 1) = "D" Or Mid(BackStr, d, 1) = "E" Or Mid(BackStr, d, 1) = "F" Or Mid(BackStr, d, 1) = "9" Or Mid(BackStr, d, 1) = "8" Then
           If Mid(BackStr, d, 1) = "A" Then
                Result1 = 10 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "B" Then
                Result1 = 11 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "C" Then
                Result1 = 12 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "D" Then
                Result1 = 13 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "E" Then
                Result1 = 14 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "F" Then
                Result1 = 15 * 16 * 16 * 65536 / 4096 '+ Result1
'                Result1 = Result1 * 16
            Else
                Result1 = CDbl(Mid(BackStr, d, 1)) * 16 * 16 * 65536 / 4096 + Result1
            End If

            If Mid(BackStr, d + 1, 1) = "A" Then
                Result1 = 10 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "B" Then
                Result1 = 11 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "C" Then
                Result1 = 12 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "D" Then
                Result1 = 13 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "E" Then
                Result1 = 14 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "F" Then
                Result1 = 15 * 16 * 65536 / 4096 + Result1
            Else
                Result1 = CDbl(Mid(BackStr, d + 1, 1)) * 16 * 65536 / 4096 + Result1
            End If



            If Mid(BackStr, d + 2, 1) = "A" Then
                Result1 = 10 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "B" Then
                Result1 = 11 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "C" Then
                Result1 = 12 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "D" Then
                Result1 = 13 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "E" Then
                Result1 = 14 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "F" Then
                Result1 = 15 * 16 + Result1
            Else
'            Dim A As String
'            A = Mid(BackStr, d + 2, 1)
                Result1 = CLng(Mid(BackStr, d + 2, 1)) * 65536 / 4096 + Result1
            End If

            If Mid(BackStr, d + 3, 1) = "A" Then
                Result1 = 10 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "B" Then
                Result1 = 11 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "C" Then
                Result1 = 12 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "D" Then
                Result1 = 13 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "E" Then
                Result1 = 14 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "F" Then
                Result1 = 15 + Result1
            Else
                Result1 = CInt(Mid(BackStr, d + 3, 1)) + Result1
            End If

               getdatafromplc = Result1 - 65536
            Else
            If Mid(BackStr, d, 1) = "A" Then
                Result1 = 10 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "B" Then
                Result1 = 11 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "C" Then
                Result1 = 12 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "D" Then
                Result1 = 13 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "E" Then
                Result1 = 14 * 16 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d, 1) = "F" Then
                Result1 = 15 * 16 * 16 * 65536 / 4096 '+ Result1
'                Result1 = Result1 * 16
            Else
                Result1 = CLng(Mid(BackStr, d, 1)) * 16 * 16 * 65536 / 4096 + Result1
            End If

            If Mid(BackStr, d + 1, 1) = "A" Then
                Result1 = 10 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "B" Then
                Result1 = 11 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "C" Then
                Result1 = 12 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "D" Then
                Result1 = 13 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "E" Then
                Result1 = 14 * 16 * 65536 / 4096 + Result1
            ElseIf Mid(BackStr, d + 1, 1) = "F" Then
                Result1 = 15 * 16 * 65536 / 4096 + Result1
            Else
                Result1 = CDbl(Mid(BackStr, d + 1, 1)) * 16 * 65536 / 4096 + Result1
            End If



            If Mid(BackStr, d + 2, 1) = "A" Then
                Result1 = 10 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "B" Then
                Result1 = 11 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "C" Then
                Result1 = 12 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "D" Then
                Result1 = 13 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "E" Then
                Result1 = 14 * 16 + Result1
            ElseIf Mid(BackStr, d + 2, 1) = "F" Then
                Result1 = 15 * 16 + Result1
            Else
                Result1 = CDbl(Mid(BackStr, d + 2, 1)) * 65536 / 4096 + Result1
            End If

            If Mid(BackStr, d + 3, 1) = "A" Then
                Result1 = 10 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "B" Then
                Result1 = 11 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "C" Then
                Result1 = 12 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "D" Then
                Result1 = 13 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "E" Then
                Result1 = 14 + Result1
            ElseIf Mid(BackStr, d + 3, 1) = "F" Then
                Result1 = 15 + Result1
            Else
                Result1 = CInt(Mid(BackStr, d + 3, 1)) + Result1
            End If

                getdatafromplc = Result1
                
                
                BackStr = ""
        End If
  Else
  Exit Function
  
  
  End If
  
  
  End Function

  Public Function rpotdata1(ByVal qsw As Integer, ByVal zfc As String) As Double
                    Dim Result3 As Double
                    Result3 = 0
                    If Mid(zfc, qsw, 1) = "A" Then
                        Result3 = 10 * (16 ^ 7) + Result3
                    ElseIf Mid(zfc, qsw, 1) = "B" Then
                        Result3 = 11 * (16 ^ 7) + Result3
                    ElseIf Mid(zfc, qsw, 1) = "C" Then
                        Result3 = 12 * (16 ^ 7) + Result3
                    ElseIf Mid(zfc, qsw, 1) = "D" Then
                        Result3 = 13 * (16 ^ 7) + Result3
                    ElseIf Mid(zfc, qsw, 1) = "E" Then
                        Result3 = 14 * (16 ^ 7) + Result3
                    ElseIf Mid(zfc, qsw, 1) = "F" Then
                        Result3 = 15 * (16 ^ 7) + Result3
                    Else
                        Result3 = Val(Mid(zfc, qsw, 1)) * (16 ^ 7) + Result3
                    End If
                    If Mid(zfc, qsw + 1, 1) = "A" Then
                        Result3 = 10 * 16 ^ 6 + Result3
                    ElseIf Mid(zfc, qsw + 1, 1) = "B" Then
                        Result3 = 11 * 16 ^ 6 + Result3
                    ElseIf Mid(zfc, qsw + 1, 1) = "C" Then
                        Result3 = 12 * 16 ^ 6 + Result3
                    ElseIf Mid(zfc, qsw + 1, 1) = "D" Then
                        Result3 = 13 * 16 ^ 6 + Result3
                    ElseIf Mid(zfc, qsw + 1, 1) = "E" Then
                        Result3 = 14 * 16 ^ 6 + Result3
                    ElseIf Mid(zfc, qsw + 1, 1) = "F" Then
                        Result3 = 15 * 16 ^ 6 + Result3
                    Else
                        Result3 = Val(Mid(zfc, qsw + 1, 1)) * 16 ^ 6 + Result3
                    End If

                    

                    If Mid(zfc, qsw + 2, 1) = "A" Then
                        Result3 = 10 * 16 ^ 5 + Result3
                    ElseIf Mid(zfc, qsw + 2, 1) = "B" Then
                        Result3 = 11 * 16 ^ 5 + Result3
                    ElseIf Mid(zfc, qsw + 2, 1) = "C" Then
                        Result3 = 12 * 16 ^ 5 + Result3
                    ElseIf Mid(zfc, qsw + 2, 1) = "D" Then
                        Result3 = 13 * 16 ^ 5 + Result3
                    ElseIf Mid(zfc, qsw + 2, 1) = "E" Then
                        Result3 = 14 * 16 ^ 5 + Result3
                    ElseIf Mid(zfc, qsw + 2, 1) = "F" Then
                        Result3 = 15 * 16 ^ 5 + Result3
                    Else
                        Result3 = Val(Mid(zfc, qsw + 2, 1)) * 16 ^ 5 + Result3
                    End If

            If Mid(zfc, qsw + 3, 1) = "A" Then
                Result3 = 10 * 16 ^ 4 + Result3
            ElseIf Mid(zfc, qsw + 3, 1) = "B" Then
                Result3 = 11 * 16 ^ 4 + Result3
            ElseIf Mid(zfc, qsw + 3, 1) = "C" Then
                Result3 = 12 * 16 ^ 4 + Result3
            ElseIf Mid(zfc, qsw + 3, 1) = "D" Then
                Result3 = 13 * 16 ^ 4 + Result3
            ElseIf Mid(zfc, qsw + 3, 1) = "E" Then
                Result3 = 14 * 16 ^ 4 + Result3
            ElseIf Mid(zfc, qsw + 3, 1) = "F" Then
                Result3 = 15 * 16 ^ 4 + Result3
            Else
                Result3 = Val(Mid(zfc, qsw + 3, 1)) * 16 ^ 4 + Result3
                
            End If
                    


           rpotdata1 = Result3

  End Function



